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

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

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

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

k = A("k")
g = B("g")
j = C("j")
h = D("h")

k.z = g
k.r = j
k.u = h
g.o = h
g.v = h
g.y = j
j.p = g
j.r = k
h.r = k
assert k.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: C = None
        self.u: D = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
j = C("j")
h = D("h")

k.z = g
k.r = j
k.u = h
g.o = h
g.v = h
g.y = j
j.p = g
j.r = k
h.r = k
assert k.u.r.u.txt == "h"