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

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

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

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

i = A("i")
j = B("j")
c = C("c")
f = D("f")
m = D("m")
d = A("d")
n = D("n")
e = D("e")
l = D("l")
k = B("k")

i.r = k
i.v = d
i.x = d
i.w = d
j.x = c
c.r = k
c.y = k
f.o = c
m.o = c
d.r = k
d.v = i
d.x = i
d.w = i
n.o = c
e.o = c
l.o = c
k.x = c
assert k.x.y.x.y.x.y.x.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: A = None
        self.x: A = None
        self.w: A = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
c = C("c")
f = D("f")
m = D("m")
d = A("d")
n = D("n")
e = D("e")
l = D("l")
k = B("k")

i.r = k
i.v = d
i.x = d
i.w = d
j.x = c
c.r = k
c.y = k
f.o = c
m.o = c
d.r = k
d.v = i
d.x = i
d.w = i
n.o = c
e.o = c
l.o = c
k.x = c
assert k.x.y.x.y.x.y.x.y.x.y.txt == "k"