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

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

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

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

m = A("m")
c = B("c")
f = C("f")
j = D("j")
l = A("l")
k = C("k")

m.w = l
m.p = c
m.o = c
c.q = l
c.t = j
c.z = j
f.r = c
f.x = c
j.u = l
l.w = m
l.p = c
l.o = c
k.r = c
k.x = c
assert j.u.p.q.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
f = C("f")
j = D("j")
l = A("l")
k = C("k")

m.w = l
m.p = c
m.o = c
c.q = l
c.t = j
c.z = j
f.r = c
f.x = c
j.u = l
l.w = m
l.p = c
l.o = c
k.r = c
k.x = c
assert j.u.p.q.w.p.txt == "c"