class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

i = A("i")
f = B("f")
h = C("h")
m = D("m")
n = E("n")
k = F("k")

i.w = m
f.q = m
h.q = k
m.p = i
m.r = i
n.u = k
n.s = f
n.w = f
n.p = m
n.t = m
n.v = m
k.p = n
assert i.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

i = A("i")
f = B("f")
h = C("h")
m = D("m")
n = E("n")
k = F("k")

i.w = m
f.q = m
h.q = k
m.p = i
m.r = i
n.u = k
n.s = f
n.w = f
n.p = m
n.t = m
n.v = m
k.p = n
assert i.w.p.w.p.txt == "i"