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

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

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

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

k = A("k")
n = B("n")
h = C("h")
a = D("a")
c = A("c")

k.x = a
n.u = c
h.v = a
h.y = n
h.u = k
a.t = n
c.x = a
assert c.x.t.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
h = C("h")
a = D("a")
c = A("c")

k.x = a
n.u = c
h.v = a
h.y = n
h.u = k
a.t = n
c.x = a
assert c.x.t.u.x.txt == "a"