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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: F = None
        self.u: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.r: C = None
        self.txt = txt

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

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

m = A("m")
c = B("c")
b = C("b")
j = D("j")
k = E("k")
f = F("f")

m.q = c
m.w = k
c.r = j
c.u = j
c.w = f
b.p = c
b.q = c
b.v = m
b.u = m
b.s = j
j.w = f
j.r = b
k.v = b
f.y = m
assert k.v.u.w.v.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: F = None
        self.u: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.r: C = None
        self.txt = txt

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

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

m = A("m")
c = B("c")
b = C("b")
j = D("j")
k = E("k")
f = F("f")

m.q = c
m.w = k
c.r = j
c.u = j
c.w = f
b.p = c
b.q = c
b.v = m
b.u = m
b.s = j
j.w = f
j.r = b
k.v = b
f.y = m
assert k.v.u.w.v.p.w.txt == "f"