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

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

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

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

i = A("i")
d = B("d")
a = C("a")
k = D("k")
j = B("j")
f = C("f")
n = B("n")

i.y = k
d.v = k
d.o = n
a.o = i
a.t = i
k.v = i
k.r = i
k.y = a
j.v = k
j.o = d
f.o = i
f.t = i
n.v = k
n.o = j
assert j.v.y.t.y.r.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

i = A("i")
d = B("d")
a = C("a")
k = D("k")
j = B("j")
f = C("f")
n = B("n")

i.y = k
d.v = k
d.o = n
a.o = i
a.t = i
k.v = i
k.r = i
k.y = a
j.v = k
j.o = d
f.o = i
f.t = i
n.v = k
n.o = j
assert j.v.y.t.y.r.y.v.txt == "i"