class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.s: F = None
        self.z: B = None
        self.r: C = None
        self.v: F = None
        self.txt = txt

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

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

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

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

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

h = A("h")
b = B("b")
d = C("d")
n = D("n")
a = E("a")
g = F("g")

h.p = g
h.s = g
h.v = g
h.z = b
h.r = d
b.r = a
d.s = b
d.x = n
d.u = a
n.v = h
n.w = g
a.u = b
g.r = a
assert g.r.u.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.s: F = None
        self.z: B = None
        self.r: C = None
        self.v: F = None
        self.txt = txt

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

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

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

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

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

h = A("h")
b = B("b")
d = C("d")
n = D("n")
a = E("a")
g = F("g")

h.p = g
h.s = g
h.v = g
h.z = b
h.r = d
b.r = a
d.s = b
d.x = n
d.u = a
n.v = h
n.w = g
a.u = b
g.r = a
assert g.r.u.r.u.r.txt == "a"