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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: F = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.q: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: E = None
        self.u: D = None
        self.s: E = None
        self.txt = txt

n = A("n")
m = B("m")
k = C("k")
e = D("e")
f = E("f")
j = F("j")

n.t = j
m.t = k
m.p = j
m.x = e
m.r = e
k.z = f
k.q = j
e.r = f
e.q = n
f.s = k
f.x = k
j.v = n
j.t = f
j.s = f
j.u = e
assert f.x.q.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: F = None
        self.x: D = None
        self.r: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.q: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: E = None
        self.u: D = None
        self.s: E = None
        self.txt = txt

n = A("n")
m = B("m")
k = C("k")
e = D("e")
f = E("f")
j = F("j")

n.t = j
m.t = k
m.p = j
m.x = e
m.r = e
k.z = f
k.q = j
e.r = f
e.q = n
f.s = k
f.x = k
j.v = n
j.t = f
j.s = f
j.u = e
assert f.x.q.u.r.txt == "f"