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

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

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

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

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

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

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

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

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

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

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

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

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

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

a.w = n
a.r = j
j.q = c
j.x = a
j.r = i
i.y = m
i.u = f
d.q = f
d.z = f
f.x = a
f.u = n
f.r = n
k.v = n
n.y = f
n.u = m
m.x = a
m.u = i
m.r = i
c.q = j
c.x = a
c.r = n
assert a.r.x.w.y.x.r.q.r.y.txt == "f"