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

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

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

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

k = A("k")
l = B("l")
h = C("h")
j = D("j")
a = A("a")

k.o = h
l.t = k
h.z = k
h.u = l
h.o = l
j.t = l
j.r = h
j.x = k
a.o = h
assert j.r.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
h = C("h")
j = D("j")
a = A("a")

k.o = h
l.t = k
h.z = k
h.u = l
h.o = l
j.t = l
j.r = h
j.x = k
a.o = h
assert j.r.z.o.txt == "h"