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

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

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

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

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

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

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

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

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

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

c.w = b
j.w = e
j.v = f
j.t = b
j.u = m
f.v = b
f.q = m
k.v = c
k.y = b
e.w = j
e.v = f
e.t = k
e.u = m
b.v = m
b.y = k
m.w = k
assert m.w.v.w.txt == "b"