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

class B:
    def __init__(self, txt: str):
        self.z: F = None
        self.t: D = None
        self.txt = txt

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

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

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

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

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

n.u = c
n.v = c
n.w = c
n.r = f
c.z = m
c.t = f
j.x = f
j.t = f
j.q = c
f.v = i
i.t = j
m.w = n
m.t = c
assert n.r.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.r: D = None
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: F = None
        self.t: D = None
        self.txt = txt

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

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

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

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

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

n.u = c
n.v = c
n.w = c
n.r = f
c.z = m
c.t = f
j.x = f
j.t = f
j.q = c
f.v = i
i.t = j
m.w = n
m.t = c
assert n.r.v.t.txt == "j"