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

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

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

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

b = A("b")
f = B("f")
n = C("n")
e = D("e")
g = C("g")
j = B("j")
d = D("d")
i = A("i")
k = D("k")

b.r = e
b.z = i
f.o = j
f.v = j
n.z = j
n.s = d
e.u = d
g.z = f
g.s = k
j.o = f
j.v = f
d.u = e
i.r = d
i.z = b
k.u = d
assert e.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: A = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
n = C("n")
e = D("e")
g = C("g")
j = B("j")
d = D("d")
i = A("i")
k = D("k")

b.r = e
b.z = i
f.o = j
f.v = j
n.z = j
n.s = d
e.u = d
g.z = f
g.s = k
j.o = f
j.v = f
d.u = e
i.r = d
i.z = b
k.u = d
assert e.u.u.u.u.u.u.u.txt == "d"