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

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

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

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

l.p = g
c.w = l
c.z = i
j.w = i
g.p = l
a.w = i
i.w = j
assert l.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

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

l.p = g
c.w = l
c.z = i
j.w = i
g.p = l
a.w = i
i.w = j
assert l.p.p.p.p.txt == "l"