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

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: A = None
        self.o: C = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
c = C("c")
e = D("e")
l = C("l")
f = B("f")
k = B("k")
j = D("j")
a = D("a")
h = A("h")

g.z = a
d.u = k
d.p = g
d.o = l
d.x = c
c.t = l
e.p = j
l.t = c
f.u = d
f.p = h
f.o = l
f.x = l
k.u = f
k.p = h
k.o = c
k.x = l
j.p = a
a.p = e
h.z = j
assert c.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: A = None
        self.o: C = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
c = C("c")
e = D("e")
l = C("l")
f = B("f")
k = B("k")
j = D("j")
a = D("a")
h = A("h")

g.z = a
d.u = k
d.p = g
d.o = l
d.x = c
c.t = l
e.p = j
l.t = c
f.u = d
f.p = h
f.o = l
f.x = l
k.u = f
k.p = h
k.o = c
k.x = l
j.p = a
a.p = e
h.z = j
assert c.t.t.t.t.t.t.txt == "c"