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

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

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

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

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

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

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

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

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

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

m.r = l
m.u = l
m.v = d
m.x = d
d.q = c
n.u = k
n.s = m
n.x = d
l.y = c
l.v = c
l.q = d
c.y = l
c.v = l
c.q = d
k.q = c
assert k.q.q.q.q.q.txt == "c"