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

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

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

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

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

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

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

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

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

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

j.y = i
m.r = c
d.o = n
d.x = l
l.z = n
l.x = j
c.z = d
c.x = j
n.o = d
n.x = l
a.r = c
i.y = j
k.o = d
k.x = c
assert c.x.y.y.y.y.y.txt == "i"