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

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

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

g = A("g")
i = B("i")
c = C("c")
d = C("d")
a = B("a")
n = A("n")
j = B("j")
m = A("m")

g.y = a
g.t = c
i.t = a
c.r = d
d.r = c
a.t = i
n.y = a
n.t = d
j.t = a
m.y = a
m.t = d
assert i.t.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
c = C("c")
d = C("d")
a = B("a")
n = A("n")
j = B("j")
m = A("m")

g.y = a
g.t = c
i.t = a
c.r = d
d.r = c
a.t = i
n.y = a
n.t = d
j.t = a
m.y = a
m.t = d
assert i.t.t.t.t.t.t.t.t.txt == "i"