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

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

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

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

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

g = A("g")
e = B("e")
c = C("c")
d = D("d")
f = E("f")
m = A("m")
l = B("l")

g.z = c
g.v = l
e.x = l
e.p = f
c.v = g
c.p = g
c.x = f
c.z = d
d.x = c
f.u = e
m.z = c
m.v = l
l.x = e
l.p = f
assert e.p.u.x.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

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

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

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

g = A("g")
e = B("e")
c = C("c")
d = D("d")
f = E("f")
m = A("m")
l = B("l")

g.z = c
g.v = l
e.x = l
e.p = f
c.v = g
c.p = g
c.x = f
c.z = d
d.x = c
f.u = e
m.z = c
m.v = l
l.x = e
l.p = f
assert e.p.u.x.x.p.txt == "f"