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.x: A = None
        self.z: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: E = None
        self.txt = txt

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

a = A("a")
f = B("f")
m = C("m")
d = D("d")
c = E("c")

a.p = m
a.t = m
f.x = a
f.z = c
m.z = f
m.t = f
d.t = a
d.s = c
c.p = a
c.y = a
c.o = m
assert c.o.t.x.p.t.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.x: A = None
        self.z: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: E = None
        self.txt = txt

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

a = A("a")
f = B("f")
m = C("m")
d = D("d")
c = E("c")

a.p = m
a.t = m
f.x = a
f.z = c
m.z = f
m.t = f
d.t = a
d.s = c
c.p = a
c.y = a
c.o = m
assert c.o.t.x.p.t.txt == "f"