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

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

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

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

f = A("f")
k = B("k")
l = C("l")
d = D("d")
n = A("n")
m = D("m")
e = C("e")

f.q = k
f.v = k
k.x = f
k.u = d
l.o = n
l.x = k
l.q = f
d.y = k
d.p = k
d.t = m
d.o = l
n.q = k
n.v = k
m.y = k
m.p = k
m.t = d
m.o = l
e.o = f
e.q = f
e.x = k
assert k.u.p.u.t.o.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
l = C("l")
d = D("d")
n = A("n")
m = D("m")
e = C("e")

f.q = k
f.v = k
k.x = f
k.u = d
l.o = n
l.x = k
l.q = f
d.y = k
d.p = k
d.t = m
d.o = l
n.q = k
n.v = k
m.y = k
m.p = k
m.t = d
m.o = l
e.o = f
e.q = f
e.x = k
assert k.u.p.u.t.o.x.x.txt == "f"