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

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

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

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

b = A("b")
f = B("f")
d = C("d")
e = D("e")
j = B("j")
n = D("n")
i = C("i")

b.y = e
b.q = e
b.v = f
f.q = j
f.y = d
f.p = e
d.o = b
d.u = j
e.y = n
j.q = f
j.y = i
j.p = e
n.y = e
i.o = b
i.u = f
assert d.o.q.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
d = C("d")
e = D("e")
j = B("j")
n = D("n")
i = C("i")

b.y = e
b.q = e
b.v = f
f.q = j
f.y = d
f.p = e
d.o = b
d.u = j
e.y = n
j.q = f
j.y = i
j.p = e
n.y = e
i.o = b
i.u = f
assert d.o.q.y.y.y.y.y.txt == "n"