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

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

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

a = A("a")
g = B("g")
b = C("b")
l = A("l")

a.p = g
g.p = a
g.u = a
g.r = b
b.q = g
b.t = a
l.p = g
assert a.p.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
b = C("b")
l = A("l")

a.p = g
g.p = a
g.u = a
g.r = b
b.q = g
b.t = a
l.p = g
assert a.p.r.t.txt == "a"