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

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

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

m = A("m")
k = B("k")
l = C("l")
c = A("c")
j = C("j")
e = C("e")
g = A("g")
a = B("a")

m.y = g
k.p = a
k.r = a
l.t = j
l.q = e
l.y = k
c.y = m
j.t = l
j.q = l
j.y = a
e.t = l
e.q = l
e.y = k
g.y = m
a.p = k
a.r = k
assert g.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
l = C("l")
c = A("c")
j = C("j")
e = C("e")
g = A("g")
a = B("a")

m.y = g
k.p = a
k.r = a
l.t = j
l.q = e
l.y = k
c.y = m
j.t = l
j.q = l
j.y = a
e.t = l
e.q = l
e.y = k
g.y = m
a.p = k
a.r = k
assert g.y.y.y.y.txt == "g"