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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.u: F = None
        self.t: F = None
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.u: F = None
        self.t: F = None
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

j.r = i
a.y = c
a.p = c
i.x = c
k.p = j
c.r = j
n.q = j
n.w = k
n.u = m
n.t = m
n.o = a
n.z = a
m.q = j
m.w = k
m.u = n
m.t = n
m.o = a
m.z = a
assert n.w.p.r.x.txt == "c"