class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: A = None
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
d = C("d")
m = D("m")
b = A("b")

n.w = d
n.u = d
n.x = d
l.u = d
l.q = n
l.o = n
l.r = n
d.x = l
m.v = d
m.o = n
m.y = n
m.q = b
b.w = d
b.u = d
b.x = d
assert n.u.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: A = None
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
d = C("d")
m = D("m")
b = A("b")

n.w = d
n.u = d
n.x = d
l.u = d
l.q = n
l.o = n
l.r = n
d.x = l
m.v = d
m.o = n
m.y = n
m.q = b
b.w = d
b.u = d
b.x = d
assert n.u.x.u.x.u.txt == "d"