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

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

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

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

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

n.p = f
n.t = f
f.u = n
l.q = f
l.x = f
l.o = f
l.s = a
a.x = n
a.p = l
a.q = l
a.s = c
c.p = f
c.t = f
assert c.p.u.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.txt = txt

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

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

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

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

n.p = f
n.t = f
f.u = n
l.q = f
l.x = f
l.o = f
l.s = a
a.x = n
a.p = l
a.q = l
a.s = c
c.p = f
c.t = f
assert c.p.u.t.u.t.txt == "f"