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

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

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

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

a = A("a")
m = B("m")
c = C("c")
n = D("n")
e = D("e")
j = B("j")
k = D("k")

a.v = c
a.y = j
m.y = j
c.r = a
n.x = c
n.s = j
n.p = a
e.x = c
e.s = j
e.p = a
j.y = m
k.x = c
k.s = j
k.p = a
assert m.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: B = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
c = C("c")
n = D("n")
e = D("e")
j = B("j")
k = D("k")

a.v = c
a.y = j
m.y = j
c.r = a
n.x = c
n.s = j
n.p = a
e.x = c
e.s = j
e.p = a
j.y = m
k.x = c
k.s = j
k.p = a
assert m.y.y.y.y.y.txt == "j"