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

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

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

e = A("e")
k = B("k")
m = C("m")

e.t = m
e.p = m
k.q = e
k.p = m
m.v = e
m.t = e
assert k.p.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
m = C("m")

e.t = m
e.p = m
k.q = e
k.p = m
m.v = e
m.t = e
assert k.p.t.t.txt == "m"