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

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

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

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

m = A("m")
b = B("b")
k = C("k")
h = D("h")
c = A("c")
g = A("g")
n = C("n")

m.w = c
m.v = b
b.x = m
k.z = b
k.o = b
h.u = m
c.w = g
c.v = b
g.w = m
g.v = b
n.z = b
n.o = b
assert c.v.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: B = None
        self.txt = txt

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

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

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

m = A("m")
b = B("b")
k = C("k")
h = D("h")
c = A("c")
g = A("g")
n = C("n")

m.w = c
m.v = b
b.x = m
k.z = b
k.o = b
h.u = m
c.w = g
c.v = b
g.w = m
g.v = b
n.z = b
n.o = b
assert c.v.x.w.txt == "c"