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

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

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

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

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

k.r = e
k.u = j
e.x = l
j.z = b
j.x = h
j.r = g
b.z = k
b.t = e
b.s = h
h.x = l
l.z = k
l.t = h
l.s = e
g.z = b
g.x = e
g.r = j
assert h.x.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: C = None
        self.txt = txt

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

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

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

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

k.r = e
k.u = j
e.x = l
j.z = b
j.x = h
j.r = g
b.z = k
b.t = e
b.s = h
h.x = l
l.z = k
l.t = h
l.s = e
g.z = b
g.x = e
g.r = j
assert h.x.z.r.txt == "e"