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

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

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

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

c = A("c")
k = B("k")
j = C("j")
f = D("f")
a = B("a")
l = C("l")
n = D("n")
g = D("g")
d = C("d")

c.r = d
k.q = c
j.v = k
j.z = c
j.u = a
f.u = c
f.y = a
f.x = d
a.q = c
l.v = k
l.z = c
l.u = a
n.u = c
n.y = a
n.x = l
g.u = c
g.y = k
g.x = l
d.v = k
d.u = k
d.z = c
assert c.r.u.q.r.u.q.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
j = C("j")
f = D("f")
a = B("a")
l = C("l")
n = D("n")
g = D("g")
d = C("d")

c.r = d
k.q = c
j.v = k
j.z = c
j.u = a
f.u = c
f.y = a
f.x = d
a.q = c
l.v = k
l.z = c
l.u = a
n.u = c
n.y = a
n.x = l
g.u = c
g.y = k
g.x = l
d.v = k
d.u = k
d.z = c
assert c.r.u.q.r.u.q.r.u.txt == "k"