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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: A = None
        self.txt = txt

e = A("e")
j = B("j")
l = C("l")
c = D("c")
m = B("m")
a = D("a")

e.p = m
e.u = c
j.u = e
j.t = c
j.o = m
l.z = e
l.v = e
c.q = l
c.y = e
m.u = e
m.t = c
m.o = j
a.q = l
a.y = e
assert a.q.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: A = None
        self.txt = txt

e = A("e")
j = B("j")
l = C("l")
c = D("c")
m = B("m")
a = D("a")

e.p = m
e.u = c
j.u = e
j.t = c
j.o = m
l.z = e
l.v = e
c.q = l
c.y = e
m.u = e
m.t = c
m.o = j
a.q = l
a.y = e
assert a.q.z.p.txt == "m"