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

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

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

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

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

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

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

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

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

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

b.u = i
h.o = l
h.p = i
h.r = i
m.p = i
m.v = h
m.x = b
m.q = b
n.w = l
l.w = n
d.u = m
c.w = n
i.p = m
i.v = h
i.x = b
i.q = b
assert d.u.p.x.u.txt == "i"