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

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

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

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

n = A("n")
b = B("b")
a = C("a")
k = D("k")
f = D("f")

n.t = a
n.q = b
n.v = b
n.p = b
b.t = n
b.s = k
a.r = k
a.z = b
a.x = b
a.s = n
k.s = a
f.s = a
assert b.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: B = None
        self.v: B = None
        self.p: B = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
a = C("a")
k = D("k")
f = D("f")

n.t = a
n.q = b
n.v = b
n.p = b
b.t = n
b.s = k
a.r = k
a.z = b
a.x = b
a.s = n
k.s = a
f.s = a
assert b.s.s.x.txt == "b"