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

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

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

l = A("l")
c = B("c")
g = C("g")
f = B("f")
m = C("m")
i = C("i")

l.p = f
c.t = i
c.w = i
g.y = i
f.t = m
f.w = m
m.y = i
i.y = g
assert i.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
g = C("g")
f = B("f")
m = C("m")
i = C("i")

l.p = f
c.t = i
c.w = i
g.y = i
f.t = m
f.w = m
m.y = i
i.y = g
assert i.y.y.y.y.txt == "i"