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

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.y: D = 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.u: A = None
        self.s: C = None
        self.q: D = None
        self.txt = txt

d = A("d")
f = B("f")
a = C("a")
c = D("c")
b = C("b")
n = A("n")
j = B("j")
l = B("l")
m = D("m")

d.x = c
f.s = b
f.v = j
f.y = m
a.x = l
c.u = n
c.s = b
c.q = m
b.x = j
n.x = m
j.s = b
j.v = l
j.y = m
l.s = b
l.v = j
l.y = c
m.u = n
m.s = b
m.q = c
assert b.x.y.q.u.x.u.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.y: D = 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.u: A = None
        self.s: C = None
        self.q: D = None
        self.txt = txt

d = A("d")
f = B("f")
a = C("a")
c = D("c")
b = C("b")
n = A("n")
j = B("j")
l = B("l")
m = D("m")

d.x = c
f.s = b
f.v = j
f.y = m
a.x = l
c.u = n
c.s = b
c.q = m
b.x = j
n.x = m
j.s = b
j.v = l
j.y = m
l.s = b
l.v = j
l.y = c
m.u = n
m.s = b
m.q = c
assert b.x.y.q.u.x.u.x.u.x.txt == "m"