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

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: C = None
        self.v: C = None
        self.txt = txt

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

i.y = c
m.o = i
m.y = i
m.v = n
a.o = g
c.x = m
c.w = a
c.v = a
j.x = m
j.w = a
j.v = a
g.o = i
g.y = i
g.v = m
n.o = i
n.y = i
n.v = g
assert a.o.o.y.v.o.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: C = None
        self.v: C = None
        self.txt = txt

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

i.y = c
m.o = i
m.y = i
m.v = n
a.o = g
c.x = m
c.w = a
c.v = a
j.x = m
j.w = a
j.v = a
g.o = i
g.y = i
g.v = m
n.o = i
n.y = i
n.v = g
assert a.o.o.y.v.o.v.v.txt == "n"