class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: C = None
        self.p: F = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

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

c.z = l
c.x = l
c.q = m
c.p = b
n.v = b
m.p = j
m.z = j
m.r = b
m.q = f
m.w = n
l.q = f
j.r = l
j.q = b
b.x = l
b.q = l
f.v = b
assert n.v.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: C = None
        self.p: F = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

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

c.z = l
c.x = l
c.q = m
c.p = b
n.v = b
m.p = j
m.z = j
m.r = b
m.q = f
m.w = n
l.q = f
j.r = l
j.q = b
b.x = l
b.q = l
f.v = b
assert n.v.x.q.txt == "f"