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

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

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

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

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

f.t = j
k.u = e
k.p = e
j.y = f
j.z = k
e.y = h
a.y = h
a.z = k
h.t = a
assert a.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

f.t = j
k.u = e
k.p = e
j.y = f
j.z = k
e.y = h
a.y = h
a.z = k
h.t = a
assert a.y.t.y.txt == "h"