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

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

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

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

n = A("n")
g = B("g")
a = C("a")
j = D("j")
b = A("b")
d = B("d")
m = A("m")
i = D("i")

n.o = a
n.v = m
g.p = a
g.t = d
g.y = i
a.q = j
j.u = a
j.t = a
b.o = a
b.v = n
d.p = a
d.t = g
d.y = i
m.o = a
m.v = n
i.u = a
i.t = a
assert d.t.p.q.t.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: A = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
a = C("a")
j = D("j")
b = A("b")
d = B("d")
m = A("m")
i = D("i")

n.o = a
n.v = m
g.p = a
g.t = d
g.y = i
a.q = j
j.u = a
j.t = a
b.o = a
b.v = n
d.p = a
d.t = g
d.y = i
m.o = a
m.v = n
i.u = a
i.t = a
assert d.t.p.q.t.q.u.txt == "a"