class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.w: C = None
        self.y: F = None
        self.txt = txt

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

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

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

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

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

g = A("g")
h = B("h")
e = C("e")
n = D("n")
l = E("l")
k = F("k")
m = F("m")
b = F("b")
a = F("a")
i = A("i")

g.x = i
g.r = n
g.w = e
g.y = b
h.q = n
h.t = b
e.r = g
e.y = m
e.t = m
n.w = i
l.t = h
k.q = n
m.q = n
b.q = n
a.q = n
i.x = g
i.r = n
i.w = e
i.y = k
assert b.q.w.x.w.r.r.w.x.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.w: C = None
        self.y: F = None
        self.txt = txt

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

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

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

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

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

g = A("g")
h = B("h")
e = C("e")
n = D("n")
l = E("l")
k = F("k")
m = F("m")
b = F("b")
a = F("a")
i = A("i")

g.x = i
g.r = n
g.w = e
g.y = b
h.q = n
h.t = b
e.r = g
e.y = m
e.t = m
n.w = i
l.t = h
k.q = n
m.q = n
b.q = n
a.q = n
i.x = g
i.r = n
i.w = e
i.y = k
assert b.q.w.x.w.r.r.w.x.r.w.txt == "i"