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

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

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

g = A("g")
c = B("c")
d = C("d")
j = A("j")
h = C("h")
k = A("k")
e = B("e")

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

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

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

g = A("g")
c = B("c")
d = C("d")
j = A("j")
h = C("h")
k = A("k")
e = B("e")

g.y = j
g.t = j
c.p = e
c.x = h
d.o = e
d.z = c
j.y = k
j.t = k
h.o = c
h.z = e
k.y = j
k.t = j
e.p = c
e.x = h
assert j.t.t.y.t.t.y.t.txt == "k"