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

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

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

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

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

g.r = l
m.u = n
k.w = l
k.q = b
k.v = e
k.p = d
c.v = l
d.u = n
e.w = l
e.q = m
e.v = k
e.p = d
l.r = g
n.v = l
b.u = c
assert b.u.v.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

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

g.r = l
m.u = n
k.w = l
k.q = b
k.v = e
k.p = d
c.v = l
d.u = n
e.w = l
e.q = m
e.v = k
e.p = d
l.r = g
n.v = l
b.u = c
assert b.u.v.r.r.r.r.r.r.r.txt == "g"