class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.s: D = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: D = None
        self.z: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.s: F = None
        self.r: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: C = None
        self.x: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

g = A("g")
c = B("c")
j = C("j")
d = D("d")
m = E("m")
h = F("h")

g.v = m
g.y = m
g.s = d
c.x = m
c.z = m
c.r = d
j.z = d
j.s = h
j.r = h
d.v = j
m.v = g
m.z = j
m.x = j
h.x = c
assert c.r.v.z.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.s: D = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: D = None
        self.z: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.s: F = None
        self.r: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: C = None
        self.x: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

g = A("g")
c = B("c")
j = C("j")
d = D("d")
m = E("m")
h = F("h")

g.v = m
g.y = m
g.s = d
c.x = m
c.z = m
c.r = d
j.z = d
j.s = h
j.r = h
d.v = j
m.v = g
m.z = j
m.x = j
h.x = c
assert c.r.v.z.v.s.txt == "h"