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

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

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

l = A("l")
d = B("d")
i = C("i")
c = B("c")
f = B("f")
g = C("g")
j = A("j")
a = C("a")

l.t = f
d.z = f
d.t = j
d.x = l
i.p = a
i.s = a
c.z = f
c.t = l
c.x = j
f.z = c
f.t = l
f.x = j
g.p = i
g.s = i
j.t = d
a.p = g
a.s = i
assert i.s.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
i = C("i")
c = B("c")
f = B("f")
g = C("g")
j = A("j")
a = C("a")

l.t = f
d.z = f
d.t = j
d.x = l
i.p = a
i.s = a
c.z = f
c.t = l
c.x = j
f.z = c
f.t = l
f.x = j
g.p = i
g.s = i
j.t = d
a.p = g
a.s = i
assert i.s.p.p.p.p.txt == "g"