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

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

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

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

c = A("c")
d = B("d")
f = C("f")
i = D("i")
h = D("h")
m = B("m")
g = C("g")
b = C("b")
e = D("e")

c.x = m
d.u = b
f.u = c
f.q = c
f.v = c
f.o = e
i.v = g
i.y = h
i.s = b
h.v = f
h.y = i
h.s = b
m.u = b
g.u = c
g.q = c
g.v = c
g.o = e
b.u = c
b.q = c
b.v = c
b.o = i
e.v = b
e.y = h
e.s = g
assert d.u.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
f = C("f")
i = D("i")
h = D("h")
m = B("m")
g = C("g")
b = C("b")
e = D("e")

c.x = m
d.u = b
f.u = c
f.q = c
f.v = c
f.o = e
i.v = g
i.y = h
i.s = b
h.v = f
h.y = i
h.s = b
m.u = b
g.u = c
g.q = c
g.v = c
g.o = e
b.u = c
b.q = c
b.v = c
b.o = i
e.v = b
e.y = h
e.s = g
assert d.u.u.x.u.txt == "b"