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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: C = None
        self.o: D = None
        self.p: B = None
        self.txt = txt

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

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

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

f.t = n
f.w = e
n.u = c
n.o = c
n.y = e
n.p = k
e.q = k
e.o = k
e.w = f
c.p = e
k.u = c
k.o = c
k.y = e
k.p = n
assert e.w.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: C = None
        self.o: D = None
        self.p: B = None
        self.txt = txt

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

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

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

f.t = n
f.w = e
n.u = c
n.o = c
n.y = e
n.p = k
e.q = k
e.o = k
e.w = f
c.p = e
k.u = c
k.o = c
k.y = e
k.p = n
assert e.w.t.p.txt == "k"