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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: A = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
b = C("b")
f = D("f")
j = E("j")

g.y = h
g.t = h
h.v = b
h.y = g
b.y = h
b.u = f
b.x = f
f.u = j
j.p = g
j.s = h
assert h.v.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: A = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
b = C("b")
f = D("f")
j = E("j")

g.y = h
g.t = h
h.v = b
h.y = g
b.y = h
b.u = f
b.x = f
f.u = j
j.p = g
j.s = h
assert h.v.y.y.txt == "g"