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

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

b = A("b")
c = B("c")
k = A("k")
m = A("m")
d = B("d")
j = A("j")
g = A("g")
e = A("e")
h = A("h")
f = B("f")

b.z = h
b.x = f
c.x = f
c.v = f
k.z = b
k.x = c
m.z = g
m.x = c
d.x = c
d.v = f
j.z = h
j.x = c
g.z = e
g.x = c
e.z = g
e.x = c
h.z = e
h.x = d
f.x = c
f.v = d
assert j.x.x.x.x.x.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
k = A("k")
m = A("m")
d = B("d")
j = A("j")
g = A("g")
e = A("e")
h = A("h")
f = B("f")

b.z = h
b.x = f
c.x = f
c.v = f
k.z = b
k.x = c
m.z = g
m.x = c
d.x = c
d.v = f
j.z = h
j.x = c
g.z = e
g.x = c
e.z = g
e.x = c
h.z = e
h.x = d
f.x = c
f.v = d
assert j.x.x.x.x.x.x.v.txt == "d"