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

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

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

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

j = A("j")
e = B("e")
b = C("b")
f = D("f")
k = A("k")
d = B("d")
m = C("m")

j.t = k
j.w = d
j.o = d
j.q = f
e.w = b
b.z = d
b.u = m
b.p = m
f.v = k
f.q = k
k.t = j
k.w = d
k.q = f
k.o = e
d.w = b
m.z = e
m.u = b
m.p = b
assert j.t.t.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: B = None
        self.q: D = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
e = B("e")
b = C("b")
f = D("f")
k = A("k")
d = B("d")
m = C("m")

j.t = k
j.w = d
j.o = d
j.q = f
e.w = b
b.z = d
b.u = m
b.p = m
f.v = k
f.q = k
k.t = j
k.w = d
k.q = f
k.o = e
d.w = b
m.z = e
m.u = b
m.p = b
assert j.t.t.o.w.txt == "b"