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

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

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

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

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

f.r = a
f.x = n
n.x = l
n.u = c
n.s = c
l.q = f
a.z = f
a.u = n
c.q = f
k.x = l
k.u = l
k.s = l
assert c.q.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

f.r = a
f.x = n
n.x = l
n.u = c
n.s = c
l.q = f
a.z = f
a.u = n
c.q = f
k.x = l
k.u = l
k.s = l
assert c.q.x.u.q.txt == "f"