class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: E = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

h = A("h")
g = B("g")
b = C("b")
c = D("c")
j = E("j")
e = F("e")
m = C("m")
d = F("d")
i = F("i")

h.y = c
h.v = j
h.x = d
g.q = i
g.x = m
g.z = c
b.t = c
b.s = e
b.r = i
c.t = g
j.t = h
e.p = m
e.y = d
m.t = c
m.s = e
m.r = e
d.p = m
d.y = i
i.p = b
i.y = e
assert g.q.p.s.p.t.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: E = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

h = A("h")
g = B("g")
b = C("b")
c = D("c")
j = E("j")
e = F("e")
m = C("m")
d = F("d")
i = F("i")

h.y = c
h.v = j
h.x = d
g.q = i
g.x = m
g.z = c
b.t = c
b.s = e
b.r = i
c.t = g
j.t = h
e.p = m
e.y = d
m.t = c
m.s = e
m.r = e
d.p = m
d.y = i
i.p = b
i.y = e
assert g.q.p.s.p.t.t.z.t.txt == "g"