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

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

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

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

k = A("k")
g = B("g")
b = C("b")
j = D("j")
h = C("h")
l = A("l")
c = C("c")
d = D("d")
f = C("f")

k.w = c
g.s = j
g.t = c
b.t = l
j.s = d
j.x = h
h.t = k
l.w = b
c.t = k
d.s = j
d.x = h
f.t = l
assert k.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
b = C("b")
j = D("j")
h = C("h")
l = A("l")
c = C("c")
d = D("d")
f = C("f")

k.w = c
g.s = j
g.t = c
b.t = l
j.s = d
j.x = h
h.t = k
l.w = b
c.t = k
d.s = j
d.x = h
f.t = l
assert k.w.t.w.txt == "c"