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

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

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

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

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

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

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

k.r = a
d.w = b
d.y = a
a.u = g
a.w = c
a.r = n
a.s = d
j.u = m
j.w = k
c.x = m
b.r = c
m.w = b
m.y = n
n.u = j
n.w = c
n.r = a
n.s = d
g.u = d
g.w = k
assert d.w.r.x.y.u.u.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

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

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

k.r = a
d.w = b
d.y = a
a.u = g
a.w = c
a.r = n
a.s = d
j.u = m
j.w = k
c.x = m
b.r = c
m.w = b
m.y = n
n.u = j
n.w = c
n.r = a
n.s = d
g.u = d
g.w = k
assert d.w.r.x.y.u.u.w.r.txt == "c"