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

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

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

c = A("c")
b = B("b")
g = C("g")

c.p = g
c.t = g
b.u = c
b.q = c
g.p = c
assert c.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
g = C("g")

c.p = g
c.t = g
b.u = c
b.q = c
g.p = c
assert c.p.p.p.txt == "g"