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

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

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

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

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

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

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

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

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

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

k.x = l
k.t = l
k.q = l
k.s = e
f.s = l
f.t = e
f.u = m
e.y = m
e.r = a
e.x = f
a.q = k
a.t = f
a.w = f
l.x = k
l.t = k
l.q = k
l.s = e
m.y = e
m.r = a
m.x = f
assert l.s.r.t.txt == "f"