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

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.p: C = None
        self.y: E = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
a = C("a")
b = D("b")
i = E("i")
h = F("h")

c.u = h
c.y = g
c.s = g
c.r = b
c.t = a
g.s = h
g.p = i
a.t = c
a.u = b
b.v = g
b.x = g
b.p = a
b.y = i
i.r = h
i.z = a
h.t = g
assert h.t.p.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.y: B = None
        self.s: B = None
        self.r: D = None
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.p: C = None
        self.y: E = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
a = C("a")
b = D("b")
i = E("i")
h = F("h")

c.u = h
c.y = g
c.s = g
c.r = b
c.t = a
g.s = h
g.p = i
a.t = c
a.u = b
b.v = g
b.x = g
b.p = a
b.y = i
i.r = h
i.z = a
h.t = g
assert h.t.p.r.t.s.txt == "h"