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

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

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

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

d = A("d")
k = B("k")
j = C("j")
h = D("h")
l = A("l")
e = B("e")
m = C("m")

d.w = k
d.o = e
d.u = l
k.q = h
j.y = m
h.z = d
l.w = e
l.o = k
l.u = d
e.q = h
m.y = j
assert j.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: B = None
        self.u: A = None
        self.txt = txt

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

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

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

d = A("d")
k = B("k")
j = C("j")
h = D("h")
l = A("l")
e = B("e")
m = C("m")

d.w = k
d.o = e
d.u = l
k.q = h
j.y = m
h.z = d
l.w = e
l.o = k
l.u = d
e.q = h
m.y = j
assert j.y.y.y.y.y.y.txt == "j"