class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: F = None
        self.r: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: E = None
        self.v: D = None
        self.x: D = None
        self.txt = txt

k = A("k")
a = B("a")
m = C("m")
n = D("n")
i = E("i")
f = F("f")
c = C("c")
d = C("d")

k.y = f
a.z = d
a.p = f
a.r = k
m.x = a
n.o = a
n.q = a
n.p = a
n.x = f
i.u = a
f.r = i
f.v = n
f.x = n
c.x = a
d.x = a
assert i.u.p.x.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: F = None
        self.r: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: E = None
        self.v: D = None
        self.x: D = None
        self.txt = txt

k = A("k")
a = B("a")
m = C("m")
n = D("n")
i = E("i")
f = F("f")
c = C("c")
d = C("d")

k.y = f
a.z = d
a.p = f
a.r = k
m.x = a
n.o = a
n.q = a
n.p = a
n.x = f
i.u = a
f.r = i
f.v = n
f.x = n
c.x = a
d.x = a
assert i.u.p.x.p.r.txt == "k"