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

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

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

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

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

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

h = A("h")
a = B("a")
i = C("i")
c = D("c")
d = E("d")
f = F("f")
l = C("l")

h.q = l
a.p = c
i.u = c
i.q = c
i.p = l
c.r = a
c.w = d
c.u = f
d.w = h
d.s = l
f.v = a
f.t = a
f.r = a
f.u = c
l.u = c
l.q = c
l.p = i
assert d.w.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

h = A("h")
a = B("a")
i = C("i")
c = D("c")
d = E("d")
f = F("f")
l = C("l")

h.q = l
a.p = c
i.u = c
i.q = c
i.p = l
c.r = a
c.w = d
c.u = f
d.w = h
d.s = l
f.v = a
f.t = a
f.r = a
f.u = c
l.u = c
l.q = c
l.p = i
assert d.w.q.p.p.txt == "l"