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

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

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

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

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

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

n.s = f
b.v = a
f.q = b
a.u = n
a.t = n
a.y = f
k.u = f
assert b.v.y.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

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

n.s = f
b.v = a
f.q = b
a.u = n
a.t = n
a.y = f
k.u = f
assert b.v.y.q.v.txt == "a"