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

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

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

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

d.p = j
d.x = j
m.o = e
m.u = j
m.t = k
j.o = e
e.p = j
e.x = j
k.o = e
k.u = j
k.t = m
assert d.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

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

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

d.p = j
d.x = j
m.o = e
m.u = j
m.t = k
j.o = e
e.p = j
e.x = j
k.o = e
k.u = j
k.t = m
assert d.p.o.p.txt == "j"