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

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

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

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

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

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

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

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

f.p = c
c.u = l
i.u = l
l.u = i
g.p = c
assert c.u.u.u.u.txt == "i"