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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: A = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: A = None
        self.txt = txt

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

d.p = b
d.o = b
d.s = b
d.x = g
b.p = a
b.x = d
g.p = f
g.u = f
a.u = f
a.t = f
a.z = g
a.v = b
a.x = d
f.z = b
f.y = d
assert a.x.x.u.y.p.txt == "b"