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

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

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

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

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

d.y = f
d.v = n
d.o = c
l.t = d
l.x = d
l.v = d
l.q = b
n.p = d
b.o = d
b.s = c
f.t = d
f.x = d
f.v = d
f.q = b
j.p = d
c.o = d
c.s = a
m.o = d
m.s = a
a.o = d
a.s = m
g.t = d
g.x = d
g.v = d
g.q = a
assert f.t.v.p.v.p.y.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: C = None
        self.o: D = None
        self.txt = txt

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

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

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

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

d.y = f
d.v = n
d.o = c
l.t = d
l.x = d
l.v = d
l.q = b
n.p = d
b.o = d
b.s = c
f.t = d
f.x = d
f.v = d
f.q = b
j.p = d
c.o = d
c.s = a
m.o = d
m.s = a
a.o = d
a.s = m
g.t = d
g.x = d
g.v = d
g.q = a
assert f.t.v.p.v.p.y.v.v.txt == "n"