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

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

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

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

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

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

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

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

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

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

n.r = f
n.x = k
a.t = l
a.q = g
f.t = n
f.u = g
f.y = b
k.q = n
g.t = n
g.u = l
g.y = b
l.t = n
l.u = g
l.y = b
b.t = l
b.q = l
d.t = l
d.q = l
assert n.r.t.x.q.x.q.x.q.txt == "n"