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

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

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: F = None
        self.s: F = None
        self.w: E = None
        self.txt = txt

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

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

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

h = A("h")
f = B("f")
a = C("a")
m = D("m")
j = E("j")
e = F("e")

h.q = a
f.t = a
f.v = a
f.w = m
f.q = e
a.q = e
a.p = e
a.s = e
a.w = j
m.p = a
m.q = h
j.w = h
e.u = a
e.p = a
e.w = f
assert h.q.w.w.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: F = None
        self.s: F = None
        self.w: E = None
        self.txt = txt

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

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

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

h = A("h")
f = B("f")
a = C("a")
m = D("m")
j = E("j")
e = F("e")

h.q = a
f.t = a
f.v = a
f.w = m
f.q = e
a.q = e
a.p = e
a.s = e
a.w = j
m.p = a
m.q = h
j.w = h
e.u = a
e.p = a
e.w = f
assert h.q.w.w.q.w.w.txt == "h"