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

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

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

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

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

f.t = h
f.u = h
e.x = k
e.t = l
h.z = e
h.s = e
h.y = e
k.w = f
k.s = f
l.w = f
l.s = f
assert k.w.t.y.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.txt = txt

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

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

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

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

f.t = h
f.u = h
e.x = k
e.t = l
h.z = e
h.s = e
h.y = e
k.w = f
k.s = f
l.w = f
l.s = f
assert k.w.t.y.x.w.txt == "f"