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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: D = None
        self.z: A = None
        self.x: E = None
        self.txt = txt

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

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

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

d.p = a
d.w = a
d.y = b
d.u = f
a.o = f
f.v = b
f.u = b
f.z = d
f.x = c
b.q = d
b.v = d
b.t = a
b.p = f
c.r = d
c.p = d
c.s = a
assert a.o.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: D = None
        self.w: B = None
        self.u: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: D = None
        self.z: A = None
        self.x: E = None
        self.txt = txt

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

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

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

d.p = a
d.w = a
d.y = b
d.u = f
a.o = f
f.v = b
f.u = b
f.z = d
f.x = c
b.q = d
b.v = d
b.t = a
b.p = f
c.r = d
c.p = d
c.s = a
assert a.o.z.u.txt == "f"