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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: A = None
        self.o: D = None
        self.p: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
a = D("a")
n = E("n")
j = F("j")

h.u = l
l.u = g
l.w = g
l.t = h
g.w = l
g.s = a
g.u = j
g.x = j
a.q = h
n.t = l
n.q = h
n.p = h
n.o = a
j.u = n
j.x = h
j.s = h
j.q = g
assert j.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: A = None
        self.o: D = None
        self.p: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
g = C("g")
a = D("a")
n = E("n")
j = F("j")

h.u = l
l.u = g
l.w = g
l.t = h
g.w = l
g.s = a
g.u = j
g.x = j
a.q = h
n.t = l
n.q = h
n.p = h
n.o = a
j.u = n
j.x = h
j.s = h
j.q = g
assert j.u.p.u.txt == "l"