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

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

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

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

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

n.r = e
n.o = k
n.q = a
d.r = n
c.p = n
c.y = n
c.q = d
b.u = k
b.t = m
b.q = e
b.o = n
m.u = a
m.t = b
m.q = e
m.o = n
k.p = n
k.y = n
k.q = d
a.p = n
a.y = n
a.q = e
e.r = n
assert e.r.q.p.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: C = None
        self.q: C = None
        self.txt = txt

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

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

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

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

n.r = e
n.o = k
n.q = a
d.r = n
c.p = n
c.y = n
c.q = d
b.u = k
b.t = m
b.q = e
b.o = n
m.u = a
m.t = b
m.q = e
m.o = n
k.p = n
k.y = n
k.q = d
a.p = n
a.y = n
a.q = e
e.r = n
assert e.r.q.p.r.r.txt == "n"