class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

e = A("e")
g = B("g")
b = C("b")
i = C("i")
d = C("d")
a = A("a")
h = B("h")
f = A("f")
c = C("c")
j = B("j")

e.q = b
e.u = a
g.y = d
b.t = f
b.z = f
b.q = c
i.t = f
i.z = e
i.q = b
d.t = e
d.z = a
d.q = c
a.q = b
a.u = e
h.y = c
f.q = d
f.u = a
c.t = a
c.z = a
c.q = d
j.y = c
assert a.u.u.u.u.u.u.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

e = A("e")
g = B("g")
b = C("b")
i = C("i")
d = C("d")
a = A("a")
h = B("h")
f = A("f")
c = C("c")
j = B("j")

e.q = b
e.u = a
g.y = d
b.t = f
b.z = f
b.q = c
i.t = f
i.z = e
i.q = b
d.t = e
d.z = a
d.q = c
a.q = b
a.u = e
h.y = c
f.q = d
f.u = a
c.t = a
c.z = a
c.q = d
j.y = c
assert a.u.u.u.u.u.u.q.q.q.txt == "d"